@using Abp.Configuration
<div ng-controller="tenant.views.settings.index as vm">
    <div class="row margin-bottom-5">
        <div class="col-xs-6">
            <div class="page-head">
                <div class="page-title">
                    <h1>
                        <span>@L("Settings")</span> <small>@L("SettingsHeaderInfo")</small>
                    </h1>
                </div>
            </div>
        </div>
        <div class="col-xs-6 text-right">
            <button class="btn btn-primary blue" ng-click="vm.saveAll()"><i class="fa fa-floppy-o"></i> @L("SaveAll")</button>
        </div>
    </div>
    <div class="portlet light margin-bottom-0">
        <div class="portlet-body">
            <uib-tabset class="tab-container tabbable-line" active="vm.activeTabIndex">
                <uib-tab heading="@L("General")" ng-show="!vm.isMultiTenancyEnabled || vm.showTimezoneSelection">
                    <div ng-if="!vm.isMultiTenancyEnabled || vm.showTimezoneSelection">
                        <div class="form-group form-md-line-input form-md-floating-label" ng-if="!vm.isMultiTenancyEnabled">
                            <input class="form-control" type="text" name="WebSiteRootAddress" ng-class="{'edited':vm.settings.general.webSiteRootAddress}" ng-model="vm.settings.general.webSiteRootAddress" required maxlength="128">
                            <label>@L("ThisWebSiteRootAddress")</label>
                            <span class="help-block">@L("ThisWebSiteRootAddress_Hint")</span>
                        </div>
                        <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="vm.showTimezoneSelection">
                            <timezone-combo selected-timezone="vm.settings.general.timezone" default-timezone-scope="@((int) SettingScopes.Tenant)" class="edited"></timezone-combo>
                            <label>@L("Timezone")</label>
                        </div>
                        <div></div>
                    </div>
                </uib-tab>

                <uib-tab heading="@L("UserManagement")">
                    <div>
                        <h4>@L("FormBasedRegistration")</h4>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_AllowSelfRegistration" class="md-check" type="checkbox" name="AllowSelfRegistration" ng-model="vm.settings.userManagement.allowSelfRegistration">
                                <label for="Setting_AllowSelfRegistration">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("AllowUsersToRegisterThemselves")
                                </label>
                                <span class="help-block">@L("AllowUsersToRegisterThemselves_Hint")</span>
                            </div>
                            <div class="md-checkbox" ng-show="vm.settings.userManagement.allowSelfRegistration">
                                <input id="Setting_IsNewRegisteredUserActiveByDefault" class="md-check" type="checkbox" name="IsNewRegisteredUserActiveByDefault" ng-model="vm.settings.userManagement.isNewRegisteredUserActiveByDefault">
                                <label for="Setting_IsNewRegisteredUserActiveByDefault">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("NewRegisteredUsersIsActiveByDefault")
                                </label>
                                <span class="help-block">@L("NewRegisteredUsersIsActiveByDefault_Hint")</span>
                            </div>
                            <div class="md-checkbox" ng-show="vm.settings.userManagement.allowSelfRegistration">
                                <input id="Setting_UseCaptchaOnRegistration" class="md-check" type="checkbox" name="UseCaptchaOnRegistration" ng-model="vm.settings.userManagement.useCaptchaOnRegistration">
                                <label for="Setting_UseCaptchaOnRegistration">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("UseCaptchaOnRegistration")
                                </label>
                            </div>
                        </div>
                    </div>

                    <div ng-if="!vm.isMultiTenancyEnabled && vm.settings.ldap.isModuleEnabled">
                        <h4>@L("LdapSettings")</h4>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_LdapIsEnabled" class="md-check" type="checkbox" name="LdapIsEnabled" ng-model="vm.settings.ldap.isEnabled">
                                <label for="Setting_LdapIsEnabled">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("EnableLdapAuthentication")
                                </label>
                            </div>
                        </div>
                        <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-show="vm.settings.ldap.isEnabled">
                            <input type="text" name="LdapDomainName" class="form-control" ng-class="{'edited':vm.settings.ldap.domain}" ng-model="vm.settings.ldap.domain" maxlength="128">
                            <label>@L("DomainName")</label>
                        </div>

                        <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-show="vm.settings.ldap.isEnabled">
                            <input type="text" name="LdapUserName" class="form-control" ng-class="{'edited':vm.settings.ldap.userName}" ng-model="vm.settings.ldap.userName" maxlength="128">
                            <label>@L("UserName")</label>
                        </div>

                        <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-show="vm.settings.ldap.isEnabled">
                            <input type="password" name="LdapPassword" class="form-control" ng-class="{'edited':vm.settings.ldap.password}" ng-model="vm.settings.ldap.password" maxlength="128">
                            <label>@L("Password")</label>
                        </div>
                    </div>

                    <div>
                        <h4>@L("OtherSettings")</h4>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_IsEmailConfirmationRequiredForLogin" class="md-check" type="checkbox" name="IsEmailConfirmationRequiredForLogin" ng-model="vm.settings.userManagement.isEmailConfirmationRequiredForLogin">
                                <label for="Setting_IsEmailConfirmationRequiredForLogin">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("EmailConfirmationRequiredForLogin")
                                </label>
                            </div>
                        </div>
                    </div>
                </uib-tab>

                <uib-tab heading="@L("Security")">
                    <div>
                        <h4>@L("PasswordComplexity")</h4>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_PasswordComplexity_UseDefaultSettings" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseDefaultSettings" ng-model="vm.settings.security.useDefaultPasswordComplexitySettings">
                                <label for="Setting_PasswordComplexity_UseDefaultSettings">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("UseDefaultSettings")
                                </label>
                            </div>
                        </div>
                        <div class="form-group form-md-line-input form-md-floating-label no-hint">
                            <input type="number" name="MinPasswordLength" class="form-control" ng-class="{'edited':vm.settings.security.passwordComplexity.minLength}" ng-model="vm.settings.security.passwordComplexity.minLength" ng-if="!vm.settings.security.useDefaultPasswordComplexitySettings">
                            <input type="number" name="MinPasswordLength" class="form-control" ng-class="{'edited':vm.settings.security.defaultPasswordComplexity.minLength}" ng-model="vm.settings.security.defaultPasswordComplexity.minLength" ng-if="vm.settings.security.useDefaultPasswordComplexitySettings" disabled>
                            <label>@L("MinPasswordLength")</label>
                        </div>
                        <div class="form-group form-md-line-input form-md-floating-label no-hint">
                            <input type="number" name="MaxPasswordLength" class="form-control" ng-class="{'edited':vm.settings.security.passwordComplexity.maxLength}" ng-model="vm.settings.security.passwordComplexity.maxLength" ng-if="!vm.settings.security.useDefaultPasswordComplexitySettings">
                            <input type="number" name="MaxPasswordLength" class="form-control" ng-class="{'edited':vm.settings.security.defaultPasswordComplexity.maxLength}" ng-model="vm.settings.security.defaultPasswordComplexity.maxLength" ng-if="vm.settings.security.useDefaultPasswordComplexitySettings" disabled>
                            <label>@L("MaxPasswordLength")</label>
                        </div>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_PasswordComplexity_UseNumbers" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseNumbers" ng-model="vm.settings.security.passwordComplexity.useNumbers" ng-if="!vm.settings.security.useDefaultPasswordComplexitySettings">
                                <input id="Setting_PasswordComplexity_UseNumbers" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseNumbers" ng-model="vm.settings.security.defaultPasswordComplexity.useNumbers" ng-if="vm.settings.security.useDefaultPasswordComplexitySettings" disabled>
                                <label for="Setting_PasswordComplexity_UseNumbers">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("UseNumbers")
                                </label>
                            </div>
                            <div class="md-checkbox">
                                <input id="Setting_PasswordComplexity_UseUpperCaseLetters" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseUpperCaseLetters" ng-model="vm.settings.security.passwordComplexity.useUpperCaseLetters" ng-if="!vm.settings.security.useDefaultPasswordComplexitySettings">
                                <input id="Setting_PasswordComplexity_UseUpperCaseLetters" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseUpperCaseLetters" ng-model="vm.settings.security.defaultPasswordComplexity.useUpperCaseLetters" ng-if="vm.settings.security.useDefaultPasswordComplexitySettings" disabled>
                                <label for="Setting_PasswordComplexity_UseUpperCaseLetters">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("UseUpperCaseLetters")
                                </label>
                            </div>
                            <div class="md-checkbox">
                                <input id="Setting_PasswordComplexity_UseLowerCaseLetters" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseLowerCaseLetters" ng-model="vm.settings.security.passwordComplexity.useLowerCaseLetters" ng-if="!vm.settings.security.useDefaultPasswordComplexitySettings">
                                <input id="Setting_PasswordComplexity_UseLowerCaseLetters" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UseLowerCaseLetters" ng-model="vm.settings.security.defaultPasswordComplexity.useLowerCaseLetters" ng-if="vm.settings.security.useDefaultPasswordComplexitySettings" disabled>
                                <label for="Setting_PasswordComplexity_UseLowerCaseLetters">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("UseLowerCaseLetters")
                                </label>
                            </div>
                            <div class="md-checkbox">
                                <input id="Setting_PasswordComplexity_UsePunctuations" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UsePunctuations" ng-model="vm.settings.security.passwordComplexity.usePunctuations" ng-if="!vm.settings.security.useDefaultPasswordComplexitySettings">
                                <input id="Setting_PasswordComplexity_UsePunctuations" class="md-check" type="checkbox" name="Setting_PasswordComplexity_UsePunctuations" ng-model="vm.settings.security.defaultPasswordComplexity.usePunctuations" ng-if="vm.settings.security.useDefaultPasswordComplexitySettings" disabled>
                                <label for="Setting_PasswordComplexity_UsePunctuations">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("UsePunctuations")
                                </label>
                            </div>
                        </div>
                    </div>

                    <div>
                        <h4>@L("UserLockOut")</h4>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_UserLockOut_IsEnabled" class="md-check" type="checkbox" name="Setting_UserLockOut_IsEnabled" ng-model="vm.settings.security.userLockOut.isEnabled">
                                <label for="Setting_UserLockOut_IsEnabled">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("EnableUserAccountLockingOnFailedLoginAttemts")
                                </label>
                            </div>
                        </div>
                        <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="vm.settings.security.userLockOut.isEnabled">
                            <input type="number" name="MaxFailedAccessAttemptsBeforeLockout" class="form-control" ng-class="{'edited':vm.settings.security.userLockOut.maxFailedAccessAttemptsBeforeLockout}" ng-model="vm.settings.security.userLockOut.maxFailedAccessAttemptsBeforeLockout">
                            <label>@L("MaxFailedAccessAttemptsBeforeLockout")</label>
                        </div>
                        <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="vm.settings.security.userLockOut.isEnabled">
                            <input type="number" name="DefaultAccountLockoutSeconds" class="form-control" ng-class="{'edited':vm.settings.security.userLockOut.defaultAccountLockoutSeconds}" ng-model="vm.settings.security.userLockOut.defaultAccountLockoutSeconds">
                            <label>@L("DefaultAccountLockoutDurationAsSeconds")</label>
                        </div>
                    </div>

                    <div ng-if="!vm.isMultiTenancyEnabled || vm.settings.security.twoFactorLogin.isEnabledForApplication">
                        <h4>@L("TwoFactorLogin")</h4>
                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="Setting_TwoFactorLogin_IsEnabled" class="md-check" type="checkbox" name="Setting_TwoFactorLogin_IsEnabled" ng-model="vm.settings.security.twoFactorLogin.isEnabled">
                                <label for="Setting_TwoFactorLogin_IsEnabled">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("EnableTwoFactorLogin")
                                </label>
                            </div>
                            <div class="md-checkbox" ng-if="vm.settings.security.twoFactorLogin.isEnabled && !vm.isMultiTenancyEnabled">
                                <input id="Setting_TwoFactorLogin_IsEmailProviderEnabled" class="md-check" type="checkbox" name="Setting_TwoFactorLogin_IsEmailProviderEnabled" ng-model="vm.settings.security.twoFactorLogin.isEmailProviderEnabled">
                                <label for="Setting_TwoFactorLogin_IsEmailProviderEnabled">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("IsEmailVerificationEnabled")
                                </label>
                            </div>
                            <div class="md-checkbox" ng-if="vm.settings.security.twoFactorLogin.isEnabled && !vm.isMultiTenancyEnabled">
                                <input id="Setting_TwoFactorLogin_IsSmsProviderEnabled" class="md-check" type="checkbox" name="Setting_TwoFactorLogin_IsSmsProviderEnabled" ng-model="vm.settings.security.twoFactorLogin.isSmsProviderEnabled">
                                <label for="Setting_TwoFactorLogin_IsSmsProviderEnabled">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("IsSmsVerificationEnabled")
                                </label>
                            </div>
                            <div class="md-checkbox" ng-if="vm.settings.security.twoFactorLogin.isEnabled">
                                <input id="Setting_TwoFactorLogin_IsRememberBrowserEnabled" class="md-check" type="checkbox" name="Setting_TwoFactorLogin_IsRememberBrowserEnabled" ng-model="vm.settings.security.twoFactorLogin.isRememberBrowserEnabled">
                                <label for="Setting_TwoFactorLogin_IsRememberBrowserEnabled">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("AllowToRememberBrowserForTwoFactorLogin")
                                </label>
                            </div>
                        </div>
                    </div>
                </uib-tab>

                <uib-tab heading="@L("EmailSmtp")" ng-if="!vm.isMultiTenancyEnabled">
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input type="email" name="DefaultFromAddress" class="form-control" ng-class="{'edited':vm.settings.email.defaultFromAddress}" ng-model="vm.settings.email.defaultFromAddress" maxlength="@Akso.Authorization.Users.User.MaxEmailAddressLength">
                        <label>@L("DefaultFromAddress")</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input type="text" name="DefaultFromDisplayName" class="form-control" ng-class="{'edited':vm.settings.email.defaultFromDisplayName}" ng-model="vm.settings.email.defaultFromDisplayName" maxlength="128">
                        <label>@L("DefaultFromDisplayName")</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input type="text" name="SmtpHost" class="form-control" ng-class="{'edited':vm.settings.email.smtpHost}" ng-model="vm.settings.email.smtpHost" maxlength="64">
                        <label>@L("SmtpHost")</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input type="number" name="SmtpPort" class="form-control" ng-class="{'edited':vm.settings.email.smtpPort}" ng-model="vm.settings.email.smtpPort" maxlength="5">
                        <label>@L("SmtpPort")</label>
                    </div>

                    <div class="md-checkbox-list">
                        <div class="md-checkbox">
                            <input id="Settings_SmtpEnableSsl" class="md-check" type="checkbox" name="SmtpEnableSsl" ng-model="vm.settings.email.smtpEnableSsl">
                            <label for="Settings_SmtpEnableSsl">
                                <span class="inc"></span>
                                <span class="check"></span>
                                <span class="box"></span>
                                @L("UseSsl")
                            </label>
                        </div>
                        <div class="md-checkbox">
                            <input id="Settings_SmtpUseDefaultCredentials" class="md-check" type="checkbox" name="SmtpUseDefaultCredentials" ng-model="vm.settings.email.smtpUseDefaultCredentials">
                            <label for="Settings_SmtpUseDefaultCredentials">
                                <span class="inc"></span>
                                <span class="check"></span>
                                <span class="box"></span>
                                @L("UseDefaultCredentials")
                            </label>
                        </div>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-show="!vm.settings.email.smtpUseDefaultCredentials">
                        <input type="text" name="SmtpDomainName" class="form-control" ng-class="{'edited':vm.settings.email.smtpDomain}" ng-model="vm.settings.email.smtpDomain" maxlength="128">
                        <label>@L("DomainName")</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-show="!vm.settings.email.smtpUseDefaultCredentials">
                        <input type="text" name="SmtpUserName" class="form-control" ng-class="{'edited':vm.settings.email.smtpUserName}" ng-model="vm.settings.email.smtpUserName" maxlength="128">
                        <label>@L("UserName")</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="!vm.setRandomPassword" ng-show="!vm.settings.email.smtpUseDefaultCredentials">
                        <input type="password" name="SmtpPassword" class="form-control" ng-class="{'edited':vm.settings.email.smtpPassword}" ng-model="vm.settings.email.smtpPassword" maxlength="128">
                        <label>@L("Password")</label>
                    </div>
                </uib-tab>

            </uib-tabset>
        </div>
    </div>
</div>